<template>
    <div class="index-container">
        <v-breadcrumb :breadcrumbData="[{name: '基础数据'}, {name: '公司基础信息'}]"></v-breadcrumb>

        <div class="g-box">
            <div class="table">
                <table class="width100 vd-table">
                    <tbody>
                    <tr>
                        <td style="width:130px">公司简称</td>
                        <td>
                            <el-input placeholder="请填写公司简称" v-model="addobj.short_name" class="width-400"/>
                        </td>
                    </tr>
                    <tr>
                        <td style="width:130px">公司名称</td>
                        <td>
                            <el-input placeholder="请填写公司名称" v-model="addobj.name" class="width-400"/>
                        </td>
                    </tr>
                    <tr>
                        <td>Logo</td>
                        <td>
                            <v-upload-image :fromData="addobj.logo" @toData="uploadTitleImage"></v-upload-image>
                            <el-alert class="mt-10" title="建议尺寸：300像素 × 300像素，无背景PNG图片"
                                      type="success"></el-alert>
                        </td>
                    </tr>
                    <tr>
                        <td>后台登录背景图</td>
                        <td>
                            <v-upload-image :fromData="addobj.bg" @toData="uploadBgImage"></v-upload-image>
                        </td>
                    </tr>
                    <tr>
                        <td>微信分享标题</td>
                        <td>
                            <el-input placeholder="请填写" v-model="addobj.share_title" class="width-400"/>
                        </td>
                    </tr>
                    <tr>
                        <td>微信分享图片</td>
                        <td>
                            <v-upload-image :fromData="addobj.share_image" @toData="uploadShareImage"></v-upload-image>
                            <el-alert class="mt-10" title="图片长宽比：5比4；建议尺寸：375像素 × 300像素"
                                      type="info"></el-alert>
                        </td>
                    </tr>
                    <tr>
                        <td>微信海报背景图</td>
                        <td>
                            <v-upload-image :fromData="addobj.share_bg" @toData="uploadShareBg"></v-upload-image>
                            <el-alert class="mt-10" title="建议尺寸：750像素 × 750像素" type="warning"></el-alert>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <el-button v-preventDbClick @click="submit" type="primary" class="width-100">确定
                            </el-button>
                        </td>
                    </tr>

                    </tbody>
                </table>

            </div>
        </div>

    </div>
</template>

<script type="text/ecmascript-6">
import request from '../../common/js/request.js';
import {tool} from "../../common/js/tool.js";
import config from '../../common/js/config.js'

export default {
    data() {
        return {
            addobj: {
                logo: '',
                short_name: '',
                name: '',
                bg: '',
                share_bg: '',
                share_title: '',
                share_image: ''
            }
        };
    },

    computed: {},

    mounted() {
    },

    created() {
        this.getData();
    },

    methods: {
        getData() {
            request({
                url: '/manage/companyInformation/one',
            }).then((res) => {
                this.addobj.name = res.data.name;
                this.addobj.short_name = res.data.short_name;
                this.addobj.logo = res.data.logo;
                this.addobj.bg = res.data.bg;
                this.addobj.share_bg = res.data.share_bg;
                this.addobj.share_image = res.data.share_image;
                this.addobj.share_title = res.data.share_title;
            })
        },
        submit() {
            request({
                url: '/manage/companyInformation/edit',
                data: this.addobj
            }).then((res) => {
                tool.message(res.msg, 'success', () => {
                    setTimeout(() => {
                        this.gotoPage('/home');
                    }, 1000)
                })
                // this.$confirm('保存数据成功！重新登录可刷新数据。', '提示', {
                //   confirmButtonText: '重新登录',
                //   cancelButtonText: '取消',
                //   distinguishCancelAndClose: true,
                //   type: 'warning'
                // }).then(() => {
                //   this.gotoPage('/login')
                // })
            })
        },
        uploadTitleImage(a) {
            this.addobj.logo = a;
        },
        uploadBgImage(a) {
            this.addobj.bg = a;
        },
        uploadShareBg(a) {
            this.addobj.share_bg = a;
        },
        uploadShareImage(a) {
            this.addobj.share_image = a;
        }
    },

};
</script>

<style lang="less" rel="stylesheet/less" scoped>
@import url("../../common/css/variable.less");
</style>
